{% extends 'layout.html' %}

{% block content %}
    <form class="form-signin" method="post" action="/login">
        {% csrf_token %}
        <h1 class="h3 mb-3 font-weight-normal">Log in to <a href='https://posthog.com'>PostHog</a></h1>

        {% if error %}
        <p data-attr="login-error">Your username and password didn't match. Please try again.</p>
        {% endif %}
        <div class='field'>
            <input type="email" name='email' id="inputEmail" placeholder="" value="{{ email }}" required autofocus>
            <label for="inputEmail">Email address</label>
        </div>
        <div class='field'>
            <input type="password" name='password' id="inputPassword" placeholder="" required>
            <label for="inputPassword">Password</label>
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
        {% if google_auth or github_auth or gitlab_auth %}
        <div class="btn-toolbar mt-2">
            {% if google_auth %}
            <a href="{% url 'social:begin' 'google-oauth2' %}{% if invite_id %}?invite_id={{ invite_id }}{% endif %}" class="btn btn-outline-dark btn-block mt-2">Sign in with Google</a>
            {% endif %}
            {% if github_auth %}
            <a href="{% url 'social:begin' 'github' %}{% if invite_id %}?invite_id={{ invite_id }}{% endif %}" class="btn btn-outline-dark btn-block mt-2">Sign in with GitHub</a>
            {% endif %}
            {% if gitlab_auth %}
            <a href="{% url 'social:begin' 'gitlab' %}{% if invite_id %}?invite_id={{ invite_id }}{% endif %}" class="btn btn-outline-dark btn-block mt-2">Sign in with GitLab</a>
            {% endif %}
        </div>
        {% endif %}
        <div class="mt-3"><small><a href='/accounts/password_reset/'>Forgot password?</a></small></div>
    </form>
{% endblock %}
